<script language="javascript">
function validate()
{
var search_query = $('#search_query').val();
if(search_query == "") {
alert("Search Query Required");
document.getElementById('search_query').focus();
return false;
}
	
}
</script>
<link rel="stylesheet" href="css/innerpage.css" type="text/css" />
<div class="mainWarpArea">
    <div class="contentwarp">
     <div class="contentwarpMiddle">
        <table border="0" cellspacing="2" cellpadding="2" width="730" class="TechnologyTbl">
          <tr>
            <td>

             <?php if($_GET['view']!='sell_books') { ?>
            <div class="search" align="center">
              <form action="index.php?page=books&view=result" method="post" onsubmit="return validate();">
                <label>Title / Author / ISBN / EAN / Annotation</label>
                <input id="search_query" name="search_query"  size="40" type="text">
                <input name="commit" value="Search" type="submit">
            </form>
			<?php } ?>
             </div>
            </td>
          </tr>
          <tr>
            <td></td>
          </tr>
          <tr>
            <td style="padding-bottom:6;padding-left:5;" colspan="2" >
              <?php if($_GET['view']==""){                      
                   echo '<h3>Recently Updated</h3>';
		
				  $qry="select * from books where (select max(id) from books)   
				and active_status ='1' order by id desc limit 0,5";
		
				$res = $base_obj->exec_query($qry);
				$data = $base_obj->fetch_row_all($res);	
				$count = count($data);
				for($i=0;$i<$count;$i++) 
				{
					if($data[$i]['cover_image']=="")
					{
					$source ='<img src="images/noimage.jpg" width="120px" />';	
					}
					else
					{
					$source ='<img width=120px  src="uploads/books/'.$data[$i]['cover_image'].'"/>';
					}
					 echo '<table border="0" class="viewTechnology">
					 <tr><td></td><td align="left"><b>'.$data[$i]['book_name'].'</b></td></tr>
					<tr><td width=130px>'.$source.'</td>
						<td valign="top">'.stripcslashes($data[$i]['book_desc']).'
					<br><b>Edition:'.$data[$i]['edition'].'
					<br>Author:'.$data[$i]['author'].'
					<br>Published:'.$data[$i]['publisher'].'
					<br>price $'.$data[$i]['price'].'</b></td></tr>
					</table><br>';	
				}
                                     
           	 }
		     if($_GET['view']=="result")
			{
				$qry="select * from books where book_name like'".$_POST['search_query']."%'
				OR author ='".$_POST['search_query']."' OR ISBN ='".$_POST['search_query']."'
				OR price like'".$_POST['search_query']."%' OR
				annotation like'%".$_POST['search_query']."%'  and active_status ='1'";
				$res = $base_obj->exec_query($qry);
				$data = $base_obj->fetch_row_all($res);				
				$count = count($data);
				if($count>0){
				for($i=0;$i<$count;$i++) 
				{
					if($data[$i]['cover_image']=="")
					{
					$source ='<img src="images/noimage.jpg" width="120px" />';	
					}
					else
					{
					$source ='<img width=120px  src="uploads/books/'.$data[$i]['cover_image'].'"/>';
					}
					 echo '<table border="0" class="viewTechnology">
						 <tr><td></td><td align="left" ><b>'.$data[$i]['book_name'].'</b></td></tr>
					<tr><td width=130px>'.$source.'</td>
					<td valign="top">'.stripcslashes($data[$i]['book_desc']).'
					<br><b>Edition:'.$data[$i]['edition'].'
					<br>Author:'.$data[$i]['author'].'
					<br>Published:'.$data[$i]['publisher'].'
					<br>price $'.$data[$i]['price'].'</b></td></tr>
					</table><br>';	
				}}
				else
				{
					echo '<p style="text-align:center;font-weight:bold">No Books Found</p>';
					
				}
			}
			  if($_GET['view']=='sell_books')
			  {?>
              <h2 style="padding-left: 20px;">Book Register</h2>
             
<form name="sellbook" method="post" onsubmit="return sellbooks();" enctype="multipart/form-data">  
       
         <table width="79%" align="center" border="0" style="border:#E4E4E4 solid 1px;">
        <tbody><tr>
          <td colspan="2" valign="middle" align="left"> <div id="error_msg" style="color:#F00; width:300px;"></div></td>
          <td valign="middle" width="50%" align="right">
           <a href="#" class="font12">Already Member? Sign In</a>
          </td>
        </tr>
        <tr>
          <td colspan="2" valign="middle" align="left">&nbsp;</td>
          <td valign="middle" align="right">&nbsp;</td>
        </tr>
        <tr height="35">
            <td style="padding-left: 20px;" valign="middle" width="14%" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" width="36%" align="left">Book Name 	* </td>
          <td valign="middle" align="left"><input class="text" name="tit" id="tit" style="width: 200px;" type="text"></td>
        </tr>
        <tr height="35">
            <td style="padding-left: 20px;" valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Book Author *	  	
  	</td>
          <td valign="middle" align="left"><input class="text" name="author" id="author" style="width: 200px;" type="text"></td>
        </tr>
        <tr height="35">
            <td style="padding-left: 20px;" valign="middle" width="14%" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" width="36%" align="left">Edition </td>
          <td valign="middle" align="left"><input class="text" name="edi" id="edi" style="width: 200px;" type="text"></td>
        </tr>
        <!--<tr height="35">
            <td style="padding-left:20px"><label>Phone Number</label></td>
            <td><input class="text" name="phone_num" type="text" /></td>
        </tr>-->
        <tr height="35">
            <td style="padding-left: 20px;" valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Book Desc *</td>
          <td valign="middle" align="left"><textarea style="width: 200px; height:100px;" name="desc" id="desc"></textarea> </td>
        </tr>
        <tr height="35">
            <td style="padding-left: 20px;" valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">ISBN No *</td>
          <td valign="middle" align="left"><input class="text" name="isbn" id="isbn" style="width: 200px;" type="text"></td>
        </tr>
         <tr height="35">
            <td style="padding-left: 20px;" valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Price * </td>
          <td valign="middle" align="left">$<input class="text" name="price" id="price" style="width: 195px;" type="text"></td>
        </tr>
        <tr height="35">
            <td style="padding-left: 20px;" valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Cover Image</td>
          <td valign="middle" align="left"><input type="file" name="upload" id="upload" /></td>
        </tr>
           <tr height="35">
            <td colspan="2" valign="middle" align="left"></td>
          <td valign="middle" align="left">
          <input class="registerbutton" value=""  type="submit">
          <input type="hidden" name="process" id="process" value=""/>
          <input type="hidden" name="module" id="module" value="book"/>
          </td>
        </tr>
    </tbody></table></form>
			  <?php } ?>
            </td>
                                    
          </tr>
          <tr>
            <td background="s_images/20/mdh2.gif"><img src="s_images/spacer.gif" height="2" width="2"></td>
          </tr>
          
        </table>
         
      </div>
      <!-- End contentwarpMiddle -->
     <div class="contentwarpRight">
      <?php include("includes/right_content.php");?>
      </div>
      <!-- End contentwarp -->
      <div style="clear:both;"></div>
    </div>
    <!-- End mainWarpArea -->
    <div style="clear:both;"></div>
  </div>
  <!-- End Wrapper -->
